import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import { Plugin as importToCDN } from "vite-plugin-cdn-import";
import { visualizer } from 'rollup-plugin-visualizer';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    VueSetupExtend(),
    importToCDN({
      modules: [
        {
          name: 'vue',
          var: 'Vue',
          path: `https://cdn.staticfile.org/vue/3.3.6/vue.global.prod.min.js`,
        },
        {
          name: 'three',
          var: 'THREE',
          path: `https://cdn.staticfile.org/three.js/0.158.0/three.min.js`,
        },
        {
          name: 'tween.ts',
          var: 'TWEEN',
          path: `https://cdn.staticfile.org/tween.js/21.0.0/tween.umd.min.js`
        },
        {
          name: 'cannon-es',
          var: 'CANNON',
          path: `https://cdn.staticfile.org/cannon.js/0.6.2/cannon.min.js`
        }
      ]
    }),
    visualizer({
      emitFile: false,
      filename: 'analysis-chart.html', // 分析图生成的文件名
      open:true // 如果存在本地服务端口，将在打包后自动展示
    })
  ],
  assetsInclude:['**/*.glb'],
  server: {
    host: '0.0.0.0',//自定义主机名
    port: 7777,//自定义端口
    // 是否开启 https
    https: false,
  },
})
